package introduction.functions

/**
 *@author LikeYouDo
 *@date 2024/12/10 14:39
 */
fun main() {
    fun printAll(vararg messages: String) {
        messages.forEach { println(it) }
    }
    printAll("Hello", "Hallo", "Salut", "Hola", "你好")                 // 2

    fun printAllWithPrefix(vararg messages: String, prefix: String) {
        messages.forEach { println(prefix + it) }
    }
    printAllWithPrefix(
        "Hello", "Hallo", "Salut", "Hola", "你好",
        prefix = "Greeting: "                                          // 4
    )

    fun log(vararg entries: String){
        //*是特殊的扩展运算符, 相当于将entries数组展开再传递给printAll函数
        printAll(*entries)
    }
    log("Hello", "Hallo", "Salut", "Hola", "你好")
}
